package com.badlogic.androidgames.game;

import com.badlogic.androidgames.framework.Game;
import com.badlogic.androidgames.framework.Pixmap;

public class TouchObject extends GameObject
{
	public TouchManager.NAME_BUTTON nameButton;
	public STATE state = STATE.NOT_TOUCH;
	
	
	public TouchObject(Pixmap tex, Vector2 pos, Vector2 size, TouchManager.NAME_BUTTON n)
	{
		super(tex, pos, size);
		this.nameButton = n;
	}
	
	public void Update(Game game)
	{
		for (int i = 0; i < 10; i++)
		{
			if (game.getInput().isTouchDown(i))
			{
				if (rectangle.contains(	game.getInput().getTouchX(i),
								     	game.getInput().getTouchY(i)))
				{
					
					if(state == STATE.NOT_TOUCH)
						state = STATE.FIRST_TOUCH;
					else 
						if(state == STATE.FIRST_TOUCH)
						state = STATE.CONTINUOUS_TOUCH;
					
					break;
						
				}
			}
			
			if(i == 9)
			{
				if(state == STATE.CONTINUOUS_TOUCH || state == STATE.FIRST_TOUCH)
					state = STATE.UP_TOUCH;
				else
					state = STATE.NOT_TOUCH;
			}
		}
	}
	
	static enum STATE
	{
		FIRST_TOUCH,
		NOT_TOUCH,
		CONTINUOUS_TOUCH,
		UP_TOUCH
	}
}
